package com.zzb.valid.dto;

import com.zzb.valid.util.constraints.UsernameLength;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 校验类
 * @author create by zhouzongbo on 2020/10/27.
 */
@Data
public class ValidDTO implements Serializable {

    private static final long serialVersionUID = 3496706298247956325L;

    @UsernameLength
    @UsernameLength(message = "测试多个注解")
    private String name;

    @NotNull
    @Range(max = 200)
    private Integer age;

    /**
     * 0: 女; 1: 男;
     */
    @NotNull
    @Range(min = 0, max = 1)
    private Integer gender;

    @NotBlank
    @Length(min = 1, max = 20)
    private String className;

    @Override
    public String toString() {
        return "ValidDTO{" + "name='" + name + '\'' + ", age=" + age + ", gender=" + gender + ", className='"
            + className + '\'' + '}';
    }
}
